-
Notifications
You must be signed in to change notification settings - Fork 13
PM-589 Fix Load more logic #1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -59,7 +60,10 @@ export const useCopilotOpportunities = (): CopilotOpportunitiesResponse => { | |||
// Flatten data array | |||
const opportunities = data ? data.flat() : [] | |||
|
|||
return { data: opportunities, isValidating, setSize: (s: number) => { setSize(s) }, size } | |||
const lastPage = data[data.length - 1] || [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if data
is not null or undefined before accessing data.length
to prevent potential runtime errors.
@@ -129,7 +129,7 @@ const CopilotOpportunityList: FC<{}> = () => { | |||
<Table | |||
columns={tableColumns} | |||
data={tableData} | |||
moreToLoad={isValidating || opportunities.length > 0} | |||
moreToLoad={hasMoreOpportunities} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable hasMoreOpportunities
should be defined and initialized properly in the component to ensure it accurately reflects whether there are more opportunities to load. Verify that hasMoreOpportunities
is correctly set and updated based on the data source.
Related JIRA Ticket:
https://topcoder.atlassian.net/browse/PM-589
What's in this PR?
Add logic to Show load more button only when there is more data to load